Test Series - java script

Test Number 59/92

Q: What does a History object contain?
A. URL
B. Parameters
C. Attribute values
D. Property
Solution: The history object contains the URLs visited by the user. By using history object, you can load previous, forward or any particular page using various methods.
Q: The history object is a part of which object?
A. Property
B. Window
C. Location
D. Screen
Solution: The window object represents an open window in a browser. The history object belongs to the Window object.
Q: How many methods are there in the History object?
A. 3
B. 4
C. 5
D. 6
Solution: There are three methods belonging to the History object namely :
back()
forward()
go()
Q: What is the purpose of the method forward()?
A. Loads any random URL in the history list
B. Loads the previous URL in the history list
C. Loads a specific URL from the history list
D. Loads the next URL in the history list
Solution: The forward() method is found in the history object. The forward() method loads the next URL in the history list.
Q: How will you update the URL displayed in the location bar?
A. location
B. location.URL
C. location.hash
D. url
Solution: The hash property sets or returns the anchor part of a URL, including the hash sign (#). The property location.hash needs to be updated to display the updated URL in the location bar.
Q: How do you add a particular state to the browsing history?
A. pushState()
B. replaceState()
C. state()
D. addstate()
Solution: The pushState() method adds a particular state to the browsing history. It pushes the given data onto the session history stack with the specified title and, if provided, URL.
Q: What does the pushState() method do?
A. Removes the state
B. Adds new state
C. Replaces the state
D. Change the state
Solution: When a web app enters a new state, it calls history.pushState() to add that state to the browsing history.
Q: Which of the following method is used to replace the current history state instead of adding a new state to the browsing history?
A. replaceState()
B. replace(state)
C. replace()
D. change()
Solution: The replaceState() method is used to replace the current history state instead of adding a new state to the browsing history. It updates the most recent entry on the history stack to have the specified data, title, and, if provided, URL.
Q: How many parameters does the replaceState() method take?
A. 2
B. 3
C. 4
D. 5
Solution: The replaceState() updates the most recent entry on the history stack to have the specified data, title, and, if provided, URL. window.history.replaceState(stateObj, title, url) : This is just like window.history.pushState, except that the current browser state is removed from the history, so you cannot hit “back” to return to it.
Q: What is the purpose of the event window.onpopstate?
A. When a state object is replaced
B. When a state object is added
C. When a state object is removed
D. When a state object is changed
Solution: The window.onpopstate event is fired whenever a state object is removed from the browser history, which occurs on browser “back” or “forward”. The object passed into a call to pushState or replaceState is provided as the state property on the event object in the “popstate” event.

You Have Score    /10